﻿

using Base.ClientUI;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace GK.WCS.Client
{
    public partial class FHeaderAsideMain : UIHeaderAsideMainFrame
    {
        public static FHeaderAsideMain main = null;
        Dictionary<String, UITitlePage> dict = new Dictionary<String, UITitlePage>();

        public FHeaderAsideMain()
        {
            InitializeComponent();
            main = this;
            Aside.TabControl = MainTabControl;
            dict.Add("垛机控制", new FrmCranes());
            dict.Add("任务列表", new TaskViewFrms());
            dict.Add("运行日志", new LogFrms());
            dict.Add("运行统计", new StatTaskFrms());
            dict.Add("参数配置", new FrmPlate());
         
            
            int i = 1001;
            foreach (var data in dict)
            {
                i++;
                AddPage(data.Value, i);
                Aside.CreateNode(data.Key, i);
            }
            //显示默认界面
            Aside.SelectFirst();
  
        }


        static ToolStripStatusLabel infoLable;

      

        private void timer1_Tick(object sender, EventArgs e)
        {
            String info = WCSHttpUtil.getNetInfo();
            if( !String.IsNullOrEmpty(info) ) {

                this.Text = "新远大WCS    " + info;

            }
        }

        private void Aside_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            UINavMenu menu = (UINavMenu)sender;
            String cotral = e.Node.Text;
            UITitlePage select = dict[cotral];
            foreach (var data in dict)
            {
                FrmCranes fc = data.Value as FrmCranes;
                if (select == fc)
                {
                    fc.timer1.Enabled = true;
                } else if (fc != null)
                {
                    fc.timer1.Enabled = false;
                }
                FrmPlate fp = data.Value as FrmPlate;
                if (select == fp) {
                    fp.timer1.Enabled = true;
                } else if (fp != null) {
                    fp.timer1.Enabled = false;
                }
            }
        }
    }
}
